#include "stm32f10x.h"                  // Device header

void LightSensor_Init(void)
{
    // Reset and clock control APB2 Peripheral Line Clock Commond
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //1. Peripheral 2. Write Enable
    GPIO_InitTypeDef GPIO_InitStructure; // 通过结构体配置初始化数据
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 
    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_13; 
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 
    GPIO_Init(GPIOB, &GPIO_InitStructure); //1. Peripheral Name 2. 结构体地址
    GPIO_SetBits(GPIOB, GPIO_Pin_13);
}

uint8_t LightSensor_In(void)
{
    uint8_t lightState = 0;
    if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13) == 1)
    {
        lightState = 1;
    }
    return lightState;
}
